package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.ProjectFeasibilityStudy;
import com.hjxr.xmgl.web.service.IProjectFeasibilityStudyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 可行性研究报告Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/study")
public class ProjectFeasibilityStudyController extends BaseController
{
    @Autowired
    private IProjectFeasibilityStudyService projectFeasibilityStudyService;

    /**
     * 查询可行性研究报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectFeasibilityStudy projectFeasibilityStudy)
    {
        startPage();
        List<ProjectFeasibilityStudy> list = projectFeasibilityStudyService.selectProjectFeasibilityStudyList(projectFeasibilityStudy);
        return getDataTable(list);
    }

    /**
     * 导出可行性研究报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:export')")
    @Log(title = "可行性研究报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectFeasibilityStudy projectFeasibilityStudy)
    {
        List<ProjectFeasibilityStudy> list = projectFeasibilityStudyService.selectProjectFeasibilityStudyList(projectFeasibilityStudy);
        ExcelUtil<ProjectFeasibilityStudy> util = new ExcelUtil<ProjectFeasibilityStudy>(ProjectFeasibilityStudy.class);
        return util.exportExcel(list, "study");
    }

    /**
     * 获取可行性研究报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:study:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return AjaxResult.success(projectFeasibilityStudyService.selectProjectFeasibilityStudyById(projectId));
    }

    /**
     * 新增可行性研究报告
     */
    @PreAuthorize("@ss.hasPermi('system:study:add')")
    @Log(title = "可行性研究报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectFeasibilityStudy projectFeasibilityStudy)
    {
        return toAjax(projectFeasibilityStudyService.insertProjectFeasibilityStudy(projectFeasibilityStudy));
    }

    /**
     * 修改可行性研究报告
     */
    @PreAuthorize("@ss.hasPermi('system:study:edit')")
    @Log(title = "可行性研究报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectFeasibilityStudy projectFeasibilityStudy)
    {
        return toAjax(projectFeasibilityStudyService.updateProjectFeasibilityStudy(projectFeasibilityStudy));
    }

    /**
     * 删除可行性研究报告
     */
    @PreAuthorize("@ss.hasPermi('system:study:remove')")
    @Log(title = "可行性研究报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable String[] projectIds)
    {
        return toAjax(projectFeasibilityStudyService.deleteProjectFeasibilityStudyByIds(projectIds));
    }
}
